package tests;

import java.util.LinkedList;
import java.util.List;

public class TestContains
{
    public static void main(String[] args)
    {
	LinkedList<Integer> linkedList = new LinkedList<Integer>();
	int size = 100000;

	for (int i = 0; i < size; i++)
	{
	    linkedList.add(i);
	}

	long time = TestContains.traditionalFor(linkedList);
	System.out.println("Traditional for: " + time + "ms");

	time = TestContains.foreach(linkedList);
	System.out.println("Foreach: " + time + "ms");
    }

    private static long traditionalFor(List<Integer> list)
    {
	long begin = System.currentTimeMillis();

	for (int i = 0; i < list.size(); i++)
	{
	    int x = list.get(i);
	}

	long end = System.currentTimeMillis();

	return end - begin;
    }

    private static long foreach(List<Integer> list)
    {
	long begin = System.currentTimeMillis();

	for (int x : list)
	{
	}

	long end = System.currentTimeMillis();

	return end - begin;
    }
}
